﻿//-----------------------------------------------------------------------
// <copyright file="StaticIconProvider.cs" author="Artak Mkrtchyan">
//     Creative Commons - GNU General Public License (http://creativecommons.org/licenses/GPL/2.0/
// </copyright>
// <author>Artak Mkrtchyan</author>
// <email>mkArtak@gmail.com</email>
// <date>13/02/2013</date>
//-----------------------------------------------------------------------

using ConsoleHoster.Model.Entities;
using System;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ConsoleHoster.Utilities
{
	internal sealed class StaticIconProvider : IExplorerItemIconProvider
	{
		private readonly ImageSource folderIcon = null;
		private readonly ImageSource driveIcon = null;

		public StaticIconProvider()
		{
			this.folderIcon = this.GetIconFromResource("pack://application:,,,/ConsoleHoster;component/View/Images/folder.png");
			this.driveIcon = this.GetIconFromResource("pack://application:,,,/ConsoleHoster;component/View/Images/diskdrive.png");
		}

		public ImageSource GetIcon(ExplorerItem argItem)
		{
			ImageSource tmpResult = null;

			ExplorerItemType tmpItemType = argItem.ItemType;
			switch (tmpItemType)
			{
				case ExplorerItemType.Drive:
					tmpResult = this.driveIcon;
					break;

				case ExplorerItemType.Folder:
					tmpResult = this.folderIcon;
					break;

				case ExplorerItemType.File:
					tmpResult = null;
					break;

				default:
					throw new ArgumentException("Invalid explorer item type");
			}

			return tmpResult;
		}

		private ImageSource GetIconFromResource(string argIconUri)
		{
			return new BitmapImage(new Uri(argIconUri));
		}
	}
}
